//
//  NetRequest.h
//  KidReading
//
//  Created by telen on 14/12/4.
//  Copyright (c) 2014年 刘赞黄Telen. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "JRASIHTTPRequest.h"

#define __NetBack__ @"NetBack"
#define __throughDict__ @"throughDict"

#pragma mark- NetRequestDelegate
@protocol NetRequestDelegate <NSObject>

@optional

- (void)netRequestFinished:(NSDictionary*)dict;
- (void)netRequestFailed:(NSDictionary*)dict;
- (void)netRequestPerReceiveData:(CGFloat)per;

@end

#pragma mark- NetRequest
@interface NetRequest : NSObject<JRASIHTTPRequestDelegate>
{
    NSString *appVersion;
    NSString *appVersionBundle;
    NSString *deviceName;
    NSString *os_ver;
    //
    NSMutableArray* keepSuccessRequestArr;
    //
    NSMutableArray* afnet_ing_Arr;
}
@property(nonatomic,strong)NSString* appVer;
@property(nonatomic,strong)NSString* appBuildVer;
@property(nonatomic,strong)NSString* osVer;
@property(nonatomic,strong)NSString* deviceName_System;

+ (NetRequest*)shareSingle;

- (NSMutableDictionary*)netRequestAddBaseInfo:(NSDictionary*)dict;
+ (NSString*)netFullUrl_Get:(NSString*)urlstr fromDict:(NSDictionary*)dict;
- (NSString*)netFullUrl_Get:(NSString*)urlstr fromDict:(NSDictionary*)dict;
+ (NSString*)netPostString_fromDict:(NSDictionary*)dict;
- (NSString*)netPostString_fromDict:(NSDictionary*)dict;
//
+ (NSDictionary*)netPostString_fromGetStr:(NSString*)refStr;
- (NSDictionary*)netPostString_fromGetStr:(NSString*)refStr;

//简单的网络请求 原则上进行下载
//通过NetRequestDelegate 回执数据
//@port 请求的地址信息
//@refsDict post请求体内容
//@iskeep no
- (void)askNet:(NSString*)port refsDict:(NSDictionary*)dict delegate:(id<NetRequestDelegate>)delegate withThroughDict:(NSDictionary*)throughDict;

- (void)askNet:(NSString*)port refsDict:(NSDictionary*)dict delegate:(id<NetRequestDelegate>)delegate withThroughDict:(NSDictionary*)throughDict keepSuccess:(BOOL)iskeep;

- (void)askNet:(NSString*)port andBaseUrl:(NSString*)baseUrl refsDict:(NSDictionary*)dict delegate:(id<NetRequestDelegate>)delegate withThroughDict:(NSDictionary*)throughDict;

- (void)askNet:(NSString*)port andBaseUrl:(NSString*)baseUrl refsDict:(NSDictionary*)dict delegate:(id<NetRequestDelegate>)delegate withThroughDict:(NSDictionary*)throughDict keepSuccess:(BOOL)iskeep;

//同步请求
-(NSDictionary*)sendSynchronous:(NSString*)URLString ref:(NSDictionary*)dict data:(NSData*)data;

//AFN 版net
- (void)askNet:(NSString*)port andBaseUrl:(NSString*)baseUrl parameters:(NSDictionary*)dict success:(void (^)(NSDictionary* retDict))success failure:(void (^)(NSError *error))failure;
- (void)cancel_all_afnet_Request;

//setting条例请求（返回data）
- (void)webViewAskNet:(NSString *)port andBaseUrl:(NSString *)baseUrl parameters:(NSDictionary *)parameters success:(void (^)(NSData* retData))success failure:(void (^)(NSError *error))failure;
@end

